diff options
| author | Adam <[email protected]> | 2026-02-09 11:34:35 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-09 11:34:35 -0600 |
| commit | dc53086c1e73d43d3a28fc4cdf161e83d09b1877 (patch) | |
| tree | 45a1d0e38de958d0886a5120b2806b21db74145b /packages/web/src/pages/[...slug].md.ts | |
| parent | f74c0339cc6315f7e7743e26b7eab47ce026c239 (diff) | |
| download | opencode-dc53086c1e73d43d3a28fc4cdf161e83d09b1877.tar.gz opencode-dc53086c1e73d43d3a28fc4cdf161e83d09b1877.zip | |
wip(docs): i18n (#12681)
Diffstat (limited to 'packages/web/src/pages/[...slug].md.ts')
| -rw-r--r-- | packages/web/src/pages/[...slug].md.ts | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/web/src/pages/[...slug].md.ts b/packages/web/src/pages/[...slug].md.ts index 51c63b5a6..dbc11d78e 100644 --- a/packages/web/src/pages/[...slug].md.ts +++ b/packages/web/src/pages/[...slug].md.ts @@ -1,13 +1,29 @@ import type { APIRoute } from "astro" import { getCollection } from "astro:content" -export const GET: APIRoute = async ({ params }) => { +function notFoundText(locals: unknown) { + if (typeof locals !== "object" || locals === null || !("t" in locals)) { + return "share.not_found" + } + const t = (locals as { t?: unknown }).t + if (typeof t !== "function") { + return "share.not_found" + } + const text = t("share.not_found") + if (typeof text === "string" && text.length > 0) { + return text + } + return "share.not_found" +} + +export const GET: APIRoute = async ({ params, locals }) => { const slug = params.slug || "index" const docs = await getCollection("docs") const doc = docs.find((d) => d.id === slug) + const notFound = notFoundText(locals) if (!doc) { - return new Response("Not found", { status: 404 }) + return new Response(notFound, { status: 404, statusText: notFound }) } return new Response(doc.body, { |
